package com.hitgo.soccer.database;

import java.sql.SQLException;
import java.util.ArrayList;

import com.danga.MemCached.MemCachedClient;
import com.hitgo.soccer.core.Props;
import com.hitgo.soccer.core.Team;

public class PropsDAO extends BaseDAO
{
	public static ArrayList<Props> getAllProps(Long lTeamID)
	{
		MemCachedClient mc = CacheFactory.getMCClient();
		String cacheKey = "getProps_" + lTeamID;
		ArrayList<Props> ap = (ArrayList<Props>) mc.get(cacheKey);
		if(ap == null)
		{
			try
			{
				ap = (ArrayList<Props>) BaseDAO.queryForList(lTeamID, "getAllProps", lTeamID);
				if(ap != null)
					mc.set(cacheKey, ap);
				
			}
			catch (SQLException e)
			{
				e.printStackTrace();
				return null;
			}
		}		
			
		return ap;
	}
	
	public static ArrayList<Props> getProps(Long lTeamID, int propID)
	{
		Props p = new Props();
		p.setUserID(lTeamID);
		p.setPropsID(propID);
		
		ArrayList<Props> ap = null;
		try
		{
			ap = (ArrayList<Props>) BaseDAO.queryForList(lTeamID, "getProps", p);
		}
		catch (SQLException e)
		{
			e.printStackTrace();
			return null;
		}
		return ap;
	}
	
	public static Integer getPackNum(Long lTeamID)
	{
		Integer pNum = 0;
		try
		{
			pNum = (Integer) BaseDAO.queryForObject(lTeamID, "getPackNum", lTeamID);
		}
		catch (SQLException e)
		{
			e.printStackTrace();
			return 0;
		}
		return pNum;
	}
	// 
	public static void updateProps(Props props)
	{
		
	}
	
	public static void insertProps(Props props)
	{
		
	}
	
	public static void delProps(Props props)
	{
		
	}
}
